package MyHashMap;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

public class map {
	public static void main(String[] args) {
	
		hashMap();
//		set();
	}
	
	public static void set() {

        Set<String> result = new HashSet<String>();
        Set<String> set1 = new HashSet<String>() {
            {
                add("鐜嬭�呰2132123233崳鑰�");
                add("鑻遍泟鑱旂洘");
                add("绌胯秺鐏嚎");
                add("鍦颁笅鍩庝笌鍕囧＋");
            }   
        };

        Set<String> set2 = new HashSet<String>() {
            {
                add("鐜嬭�呰崳鑰�");
                add("鍦颁笅鍩庝笌鍕囧＋");
                add("榄斿吔涓栫晫");
            }
        };
        
        Set<String> set3 = new TreeSet<String>() {
            {
                add("3");
                add("1");
                add("2");
            }
        };
        System.out.println("鏈夊簭锛�" + set3);
        
        result.clear();//k绌虹殑set闆嗗悎
        result.addAll(set1);
        set1.retainAll(set2);
        System.out.println("浜ら泦锛�" + result);

        result.clear();
        result.addAll(set1);
        result.removeAll(set2);
        System.out.println("宸泦锛�" + result);

        result.clear();
        result.addAll(set1);
        result.addAll(set2);
        System.out.println("骞堕泦锛�" + result);

    }

	public static  void hashMap() {
		Map<String, String> hashMap = new HashMap<String, String>();
		hashMap.put("sam01", "sam0");
		hashMap.put("sam", "valueabc");
		hashMap.put("sam", "valueabc2");//HashMap鐩稿悓鐨刱ey锛屼細琚鐩栥�� 
//			System.out.println(hashMap.get("sam"));
			Set<String> s=hashMap.keySet();
			Iterator <String> i= s.iterator();
			while(i.hasNext()){
				System.out.println(i.next());
			}
			Collection<String> c=hashMap.values();
			
			Iterator <String> ic= c.iterator();
			while(ic.hasNext()){
				System.out.println(ic.next());
			}
	}

}
